home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 892 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: double const declarations
  5. Date: 28 Mar 1996 15:56:12 GMT
  6. Organization: Comp Sci, University of Melbourne
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4jdvnj$o35@mulga.cs.mu.OZ.AU>
  9. References: <4jc2fa$bqu@arl-news-svc-2.compuserve.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. X-Nntp-Posting-Host: munta.cs.mu.oz.au
  12. Content-Length: 679
  13. X-Lines: 23
  14. Originator: clamage@taumet
  15.  
  16. Philippe Verdy <100105.3120@compuserve.com> writes:
  17.  
  18. >template <class T, class CT>
  19. >class SmartPtr2  {
  20. >   SmartPtr2(T* p) { mp = const_cast<CT>(p) ; }
  21. >   CT & Dereference() {
  22. >     return *mp ;
  23. >   }
  24. > private :
  25. >   CT *mp ;
  26. >} ;
  27. >template <class T> class ConstSmartPtr : SmartPtr<T, T> {} ;
  28. >template <class T> class FreeSmartPtr : SmartPtr<T, const T> {} ;
  29.  
  30. You forgot to delegate the constructors.
  31.  
  32. (Of course, if C++ supported tempate typedefs, there wouldn't be
  33. any need to delegate constructors in examples like this.
  34. Unfortunately it doesn't.)
  35.  
  36. --
  37. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  38. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  39.  
  40.  
  41. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  42. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  43. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  44. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  45. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  46.